package UIComponents.kfhd
{
	import Classes.GameUtils.GU_filters;
	import Classes.GameUtils.MyTipSprite;
	import Classes.GameUtils.ToolTip_Sprite;
	
	import UIComponents.IUseItem;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class ContentDieScore extends Sprite
	{
		public var count:uint=0;
		public var _item:IUseItem;
		public function ContentDieScore()
		{
			( this.getChildByName("txtCount") as TextField).selectable	=	false;
			setCount(0);
		}
		
		public function  init():void
		{
			ToolTip_Sprite.getInstance().setTip( ( this.getChildByName("item1") as DisplayObject),new MyTipSprite("100Q点积分奖励:急救纱布绷带2个"),ToolTip_Sprite.DIRECTION_LEFT);
			ToolTip_Sprite.getInstance().setTip( ( this.getChildByName("item2") as DisplayObject),new MyTipSprite("200Q点积分奖励:薯条1个"),ToolTip_Sprite.DIRECTION_LEFT);
			ToolTip_Sprite.getInstance().setTip( ( this.getChildByName("item3") as DisplayObject),new MyTipSprite("500Q点积分奖励:深夜12发"),ToolTip_Sprite.DIRECTION_LEFT);
		}
		
		public function setCount(v:uint=0):void
		{
			this.count	=	v;
			( this.getChildByName("txtCount") as TextField).text	=	"您当天的积分:" + v.toString();
		}
		
		/**
		 *设定可使用的道具对象 
		 * @param item
		 * 
		 */		
		public function setItem(item:IUseItem):void
		{
			this._item=item;
			if(this._item)
			{
				this.addChild( this._item.itemPic);				
			}
		}
		
		public function setItemsVisible(noItems:String,yesItems:String=""):void
		{//"10320001|5-10410001|6-11000007|7"


			var rewardAry	=	["10320001","10410001","11000007"];
			var visibleAry:Array	=	[true,true,true];
			var noAry:Array			=	noItems.split("-");
			var yesAry:Array		=	yesItems.split("-");
			if(noItems.length < 1){
				(this.getChildByName("btn1") as DisplayObject).visible		=	false;
			}
			else{
				(this.getChildByName("btn1") as DisplayObject).visible		=	true;
			}
			
			
			
			( this.getChildByName("item1") as DisplayObject).filters	=	[GU_filters.grayfilter];
			( this.getChildByName("item2") as DisplayObject).filters	=	[GU_filters.grayfilter];
			( this.getChildByName("item3") as DisplayObject).filters	=	[GU_filters.grayfilter];
			
			
			for( var rewardi:uint	=	0; rewardi<rewardAry.length; rewardi++)
			{
				for( var noi:uint	=	0; noi<noAry.length; noi++)
				{
					if( rewardAry[rewardi]	==	( (noAry[noi] as String).split("|"))[0])
					{
						for(var yesi:uint=0; yesi<yesAry.length; yesi++)
						{
							if( yesAry[yesi]  != rewardAry[rewardi]){
								( this.getChildByName("item"+(rewardi+1)) as DisplayObject).filters	=	null;
							}
							else
								( this.getChildByName("item"+(rewardi+1)) as DisplayObject).filters	=	[GU_filters.grayfilter];
						}
					}
				}
			}
		}
		
		public function setPic(dis:DisplayObject):void
		{
			this.addChild(dis);
		}
	}
}